package cn.zt.service.impl;

import cn.zt.dao.UserDao;
import cn.zt.model.User;
import cn.zt.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserDao userDao;

    @Transactional(propagation = Propagation.SUPPORTS)
    @Override
    public boolean queryUserNameIsExist(String userName) {
        User result = userDao.selectOne(userName);
        return result == null ? false : true;
    }

    @Transactional(propagation = Propagation.REQUIRED)
    @Override
    public void saveUser(User user) {
        userDao.saveUser(user);
    }

    @Override
    public User queryUserForLogin(String name, String password) {
        return userDao.queryUserForLogin(name,password);
    }
}

